package io.bdmc.modules.bss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.bdmc.common.utils.MyPage;
import io.bdmc.modules.bss.entity.DeviceRouteConfig;
import io.bdmc.modules.bss.mapper.DeviceRouteConfigMapper;
import io.bdmc.modules.bss.service.IDeviceRouteConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 路由参数配置 服务实现类
 * </p>
 *
 * @author 黄露
 * @since 2021-06-07
 */
@Service
public class DeviceRouteConfigServiceImpl extends ServiceImpl<DeviceRouteConfigMapper, DeviceRouteConfig> implements IDeviceRouteConfigService {
    @Autowired
    DeviceRouteConfigMapper _devicerouteconfigMapper;

    @Override
    public MyPage<DeviceRouteConfig> mySelectPage(MyPage<DeviceRouteConfig> myPage) {
        return _devicerouteconfigMapper.mySelectPage(myPage);
    }

    @Override
    public List<DeviceRouteConfig> selectByRouteId(Integer routeId) {
        LambdaQueryWrapper<DeviceRouteConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DeviceRouteConfig::getRouteId,routeId);
        return list(wrapper);
    }

    @Override
    public DeviceRouteConfig selectByRouteIdAndChannel(Integer routeId, Integer channel) {
        QueryWrapper<DeviceRouteConfig> wrapper = new QueryWrapper<>();
        wrapper.eq("route_id",routeId).eq("channel",channel).last("limit 1");
        return getOne(wrapper);
    }
}
